import {getCompanyList} from '../api';
import moment from 'moment';
export const formItems = [
  {
    label: '轮播图ID',
    name: 'id',
    type: 'input',
    itemProps: {
      disabled: true
    }
  },
  {
    label: '所属企业',
    name: 'company_id',
    type: 'select',
    required: true,
    asyncOptions: {
      api: getCompanyList,
      dataField: 'list',
      optionFields: {
        label: 'name',
        value: 'id',
      },
    }
  },
  {
    label: '标题',
    name: 'title',
    value: '',
    type: 'input',
    required: true
  },
  {
    label: '发布位置',
    name: 'position',
    value: [],
    type: 'select',
    required: true,
    itemProps: {
      options: [
        {label: '头图', value: 0}
      ]
    }
  },
  
  {
    label: '图片',
    name: 'banner_img',
    type: 'Uploader',
    itemProps: {
      multiple: false,
      maxLen: 1
    },
    required: true,
  },
  {
    label: '显示顺序',
    name: 'sort',
    type: 'input-number',
    required: true,
  },
  {
    label: '展示起止时间',
    name: 'dateRange',
    value: [],
    valueFields: ['start_at', 'end_at'],
    valueType: 'string',
    type: 'range-picker',
    required: true,
    itemProps: {
      format: 'YYYY-MM-DD HH:mm:ss',
      showTime: { defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')] }
    }
  },
  {
    label: '跳转类型',
    name: 'jump_type',
    type: 'select',
    required: true,
    itemProps: {
      options: [
        {
          label: '自定义',
          value: 1,
        },
        {
          label: '不跳转',
          value: 0,
        },
      ]
    }
  },
  {
    label: '跳转地址',
    name: 'url',
    type: 'input',
    hidden(formState){
      return formState.jump_type != 1
    },
  },
];

export const formItems2Rules = {
  
};
